//
//  VCOf2ndFirstItem.m
//  UI09_UITabBarController
//
//  Created by Scott on 16/3/21.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "VCOf2ndFirstItem.h"

@interface VCOf2ndFirstItem ()

@property (nonatomic, retain) UIButton *button;

@end

@implementation VCOf2ndFirstItem
- (void)dealloc {
    [_button release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self createButton];
}


- (void)createButton {
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    
    self.button.frame = CGRectMake(50, 80, self.view.frame.size.width - 100, 40);
    
    [self.button setTitle:@"地图" forState:UIControlStateNormal];
    
    [self.view addSubview:self.button];
    
    self.button.backgroundColor = [UIColor yellowColor];
    
    [self.button addTarget:self action:@selector(handleDitu:) forControlEvents:UIControlEventTouchUpInside];
    
}



- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    
    if (self.tabBarController.selectedIndex == 0) {
        
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    
    
    
    
}

/** 跳转到TabBar 第二个Item */
- (void)handleDitu:(UIButton *)button {
    
    
    self.tabBarController.selectedViewController = self.tabBarController.viewControllers[1];
    
    // 方案3:

//    [self.navigationController popToRootViewControllerAnimated:YES];
    

    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
